/****************************************************************************/
/* File: scs-input.cpp                                                      */
/* Desc: Implementation file for the input manager type                     */
/* Created: 2014-11-12                                                      */
/* Revised: 2014-11-16                                                      */
/* Authors: Sterling P. de Mille                                            */
/****************************************************************************/

// specification file
#include "scs-input.h"

SCSinput* SCSinput::m_pkSingleton = NULL;

SCSinput::SCSinput ()
{
	assert(!m_pkSingleton);
	m_pkSingleton = this;

	m_iCloseWindow = SCS_FALSE;
}

SCSinput::~SCSinput ()
{
	assert(m_pkSingleton);
	m_pkSingleton = NULL;

	m_iCloseWindow = SCS_FALSE;
}

SCSbool SCSinput::CloseWindow ()
{
	return m_iCloseWindow;
}

void SCSinput::Update ()
{
	SDL_PumpEvents();
	m_kKeyboard.Update();
	m_kMouse.Update();
	m_kController.Update();
	m_iCloseWindow = SCS_FALSE;
	SDL_Event kEvent;
	while (SDL_PollEvent(&kEvent)) {
		switch(kEvent.type) {
		case SDL_QUIT:
			m_iCloseWindow = SCS_TRUE;
			break;
		case SDL_MOUSEBUTTONDOWN:
			switch(kEvent.button.button){
			case SDL_BUTTON_WHEELUP:
				m_kMouse.ScrollUp();
				break;
			case SDL_BUTTON_WHEELDOWN:
				m_kMouse.ScrollDown();
				break;
			}
			break;
		default:
			break;
        }
    }
}
